package com.neu.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neu.dao.DiseaseDao;
import com.neu.entity.Admin;
import com.neu.entity.Disease;
import com.neu.entity.Params;
import com.neu.exception.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiseaseService {

    @Autowired
    private DiseaseDao diseaseDao;

    public PageInfo<Disease> findBySearch(Params params) {
        PageHelper.startPage(params.getPageNum(),params.getPageSize());
        //接下来的查询会自动按照当前开启的分页设置来查询
        List<Disease> list = diseaseDao.findBySearch(params);
        return PageInfo.of(list);
    }


    public void add(Disease disease) {

        diseaseDao.insertSelective(disease);
    }

    public void delete(Integer id) {
        //diseaseDao.deleteById(id);
        diseaseDao.deleteByPrimaryKey(id);
    }

    public void update(Disease disease) {
        diseaseDao.updateByPrimaryKey(disease);
    }
}
